package edu.mse.camel.client.chat.handler;

import edu.mse.camel.client.chat.message.MessageList;
import edu.mse.camel.client.eventbus.pubsub.ISubscriber;
import edu.mse.camel.client.events.EventIDs;
import edu.mse.camel.client.events.IEvent;
import edu.mse.camel.client.events.server.NotifySessionParticipantChange;
import edu.mse.camel.client.session.team.TeamList;

/*
 * This handler is to handle the situation that
 * 1) someone else join/leave the session
 * 2) the user just join the session
 * 3) the user just leave the session
 * 
 *   The server would provide info in NOTIFY_SESSION_PARTICIPANT_CHANGE_EVENT
 * to indicate if the user is current wants to leave the session. When 
 * user first join the session, the name of "me" in ParticipantList should
 * be updated. When the user leave the session, the content in participantList
 * should be cleared. 
 * 
 */

public class UpdateParticipantEventHandler implements ISubscriber {

//	private final String handlerName = "Update Participant Event Handler";
	
	@Override
	public void notifyEvent(IEvent e) {
		if (e.getEventID().equalsIgnoreCase(EventIDs.NOTIFY_SESSION_PARTICIPANT_CHANGE_EVENT)){
			
			NotifySessionParticipantChange npcEvent = (NotifySessionParticipantChange) e;

//			if(npcEvent.isInSession()){
//				if(TeamList.getInstance().getMe().getStatus() != 
//					ITeamMember.STATUS.SESSION) {
//					TeamList.getInstance().setMyStatus(ITeamMember.STATUS.SESSION);
//					MessageList.getInstance().getMessages().clear();
//				}
//				TeamList.getInstance().populateParticipant();
//			} else {
////				TeamList.getInstance().getParticipant().clear();
//				TeamList.getInstance().getMe().setStatus(ITeamMember.STATUS.ONLINE);
//			}
		}
	}
}
